import os
from django.core.wsgi import get_wsgi_application

# 启动django
from tornado.httpclient import AsyncHTTPClient

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
get_wsgi_application()
import settings
import tornado.httpserver
import tornado.ioloop
import tornado.wsgi
from tornado.options import parse_command_line

from app_urls import urls

AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")


def run():
    parse_command_line()
    tornado_env = settings.TORNADO_ENV
    tornado_application = tornado.web.Application(urls, **tornado_env)
    tornado_server = tornado.httpserver.HTTPServer(tornado_application, xheaders=True, max_buffer_size=500000000)
    tornado_server.listen(9000)
    tornado.ioloop.IOLoop.instance().start()


if __name__ == "__main__":
    run()
